//
//  CashModel.m
//  DaJiang
//
//  Created by sally on 16/10/29.
//  Copyright © 2016年 jiniu. All rights reserved.
//

#import "CashModel.h"

@implementation CashModel

+ (BOOL)propertyIsOptional:(NSString *)propertyName {
  return YES;
}

//提现页面
+ (void)queryCashAccountWithCompletion:(void (^)(CashModel *cashModel))completion {
  [self cleanLastError];

  completion_t _completion = ^(NSDictionary *resultObject, NSInteger code, NSString *description) {
    CashModel *cashModel = nil;

    if (code == SUCCESS_RESULT) {
      cashModel = [[CashModel alloc] initWithDictionary:resultObject error:nil];
    } else {
      [self setLastError:[NSError errorWithDomain:description code:code userInfo:nil]];
    }

    completion(cashModel);
  };

  error_t _error = ^(NSError *error) {
    [self setLastError:error];
    completion(nil);
  };

  ExpertInterface *interface = [[ExpertInterface alloc] init];
  [interface queryCashAccountWithCompletion:_completion error:_error];
}

@end

@implementation CashSummaryModel

+ (BOOL)propertyIsOptional:(NSString *)propertyName {
  return YES;
}

+ (JSONKeyMapper *)keyMapper {
  return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id" : @"summaryid" }];
}

//提现
+ (void)takeCashWithValue:(NSString *)value
               completion:(void (^)(CashSummaryModel *summaryModel))completion {
  [self cleanLastError];

  completion_t _completion = ^(NSDictionary *resultObject, NSInteger code, NSString *description) {
    CashSummaryModel *summaryModel = nil;

    if (code == SUCCESS_RESULT) {
      summaryModel = [[CashSummaryModel alloc] initWithDictionary:resultObject error:nil];
    } else {
      [self setLastError:[NSError errorWithDomain:description code:code userInfo:nil]];
    }

    completion(summaryModel);
  };

  error_t _error = ^(NSError *error) {
    [self setLastError:error];
    completion(nil);
  };

  ExpertInterface *interface = [[ExpertInterface alloc] init];
  [interface takeCashWithValue:value completion:_completion error:_error];
}

@end

@implementation CashLogModel

+ (BOOL)propertyIsOptional:(NSString *)propertyName {
  return YES;
}

+ (JSONKeyMapper *)keyMapper {
  return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id" : @"logid" }];
}

@end

@implementation CashLogData

+ (BOOL)propertyIsOptional:(NSString *)propertyName {
  return YES;
}

@end
